package com.iris.live.services.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by lusong on 2017/5/25.
 */
public class GetConfigureInfoUtils {
    static Properties pros = null;

    private static Logger logger = LoggerFactory.getLogger(GetConfigureInfoUtils.class);

    private static String env = null;

    static {   //程序启动时加载,只会被加载一次
        pros = new Properties();

        if (System.getenv("env") == null) {
            env = System.getProperty("env");
        } else {
            env = System.getenv("env");
        }
        try {
            //获取配置文件
            pros.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("application." + env + ".properties"));
        } catch (IOException e) {
            logger.error("获取配置文件程序异常", e);
        }
    }

    public static String getConfigureInfo(String configureName) {
        if ("file_group".equals(configureName)) {
            return "LSH";
        }
        return pros.getProperty(configureName);
    }
}
